`ifndef APB_MEM_SV
`define APB_MEM_SV


class apb_mem #(DW = 32, AW = 32) extends uvm_object;

	logic [DW - 1 : 0] mem[int];

	`uvm_object_param_utils(apb_mem)

	function new(string name = "apb_mem");
		super.new(name);
	endfunction : new

	function put_data(int addr, logic[DW - 1 : 0] data);
		this.mem[addr] = data;
		`uvm_info(get_type_name(), $sformatf("APB-Memory Write. Address:%0h, Data:%0h", addr, data), UVM_LOW)
	endfunction : put_data

	function logic[DW - 1 : 0] get_data(int addr);
		if(this.mem.exists(addr)) begin
			get_data = mem[addr];
			`uvm_info(get_type_name(), $sformatf("APB-Memory Read. Address:%0h, Data:%0h", addr, get_data), UVM_LOW)
		end
		else begin
			get_data = $urandom_range(32'hFFFF_FFFF);
			`uvm_error($sformatf("APB-Memory Read Error: read undefined address. Error Address:%0h, Random Data:%0h", addr, get_data), UVM_LOW)
		end
	endfunction : get_data

endclass : apb_mem


`endif // APB_MEM_SV
